package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.common.core.domain.entity.WebDocument;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IWebDocumentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 文档（网页签章）Controller
 * 
 * @author ess
 * @date 2021-10-18
 */
@RestController
@RequestMapping("/system/webDocument")
public class WebDocumentController extends BaseController
{
    @Autowired
    private IWebDocumentService webDocumentService;

    /**
     * 查询文档（网页签章）列表
     */
    @PreAuthorize("@ss.hasPermi('system:webDocument:list')")
    @GetMapping("/list")
    public TableDataInfo list(WebDocument webDocument)
    {
        startPage();
        List<WebDocument> list = webDocumentService.selectWebDocumentList(webDocument);
        return getDataTable(list);
    }

    /**
     * 导出文档（网页签章）列表
     */
    @PreAuthorize("@ss.hasPermi('system:webDocument:export')")
    @Log(title = "文档（网页签章）", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WebDocument webDocument)
    {
        List<WebDocument> list = webDocumentService.selectWebDocumentList(webDocument);
        ExcelUtil<WebDocument> util = new ExcelUtil<WebDocument>(WebDocument.class);
        return util.exportExcel(list, "文档（网页签章）数据");
    }

    /**
     * 获取文档（网页签章）详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:webDocument:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(webDocumentService.selectWebDocumentById(id));
    }

    /**
     * 新增文档（网页签章）
     */
    @PreAuthorize("@ss.hasPermi('system:webDocument:add')")
    @Log(title = "文档（网页签章）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WebDocument webDocument)
    {
        return toAjax(webDocumentService.insertWebDocument(webDocument));
    }

    /**
     * 修改文档（网页签章）
     */
    @PreAuthorize("@ss.hasPermi('system:webDocument:edit')")
    @Log(title = "文档（网页签章）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WebDocument webDocument)
    {
        return toAjax(webDocumentService.updateWebDocument(webDocument));
    }

    /**
     * 删除文档（网页签章）
     */
    @PreAuthorize("@ss.hasPermi('system:webDocument:remove')")
    @Log(title = "文档（网页签章）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(webDocumentService.deleteWebDocumentByIds(ids));
    }
}
